#include <cctype>
#include <cstdio>
#define lowbit(x) (x & (-x))

typedef long long ll;
const int N = 55, mod = 998244353;
int n, a[N], buk[10];
ll c[N][N];

inline ll mulPerm(int t) {
  ll res = 1;
  for (int i = 0; i < 10; ++i) {
    res *= c[t][buk[i]];
    t -= buk[i];
  }
  return res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("CantorExpansion.in", "r", stdin);
  freopen("CantorExpansion.out", "w", stdout);
#endif
#endif
  char ch;
  while (isdigit(ch = getchar())) buk[a[++n] = ch - '0']++;
  ll ans = 0;
  c[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j <= n; ++j) { c[i][j] = c[i - 1][j] + c[i - 1][j - 1]; }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < a[i]; ++j) {
      if (buk[j]) {
        buk[j]--;
        ans += mulPerm(n - i);
        buk[j]++;
      }
    }
    buk[a[i]]--;
  }
  printf("%lld", ans);
  return 0;
}